package org.rrs.duker.ui;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import org.rrs.duker.R;
import org.rrs.duker.pojo.SummaryInfo;

import java.util.List;

/**
 * Created by zhongjian on 16-7-8.
 */
public class NormalRecyclerViewAdapter extends RecyclerView.Adapter<NormalRecyclerViewAdapter.ViewHolder> {

    private LayoutInflater mInflater;
    private List<SummaryInfo> mDateList;

    public NormalRecyclerViewAdapter(Context context, List<SummaryInfo> dates) {
        mInflater = LayoutInflater.from(context);
        mDateList = dates;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView mTitle;
        TextView mSummary;
        TextView mTime;

        public ViewHolder(View arg0) {
            super(arg0);
        }
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View view = mInflater.inflate(R.layout.suminfolist_item, viewGroup, false);
        ViewHolder viewHolder = new ViewHolder(view);
        viewHolder.mTitle = (TextView) view.findViewById(R.id.tv_suminfo_title);
        viewHolder.mSummary = (TextView) view.findViewById(R.id.tv_suminfo_summary);
        viewHolder.mTime = (TextView) view.findViewById(R.id.tv_suminfo_time);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(final ViewHolder viewHolder, final int i) {
        viewHolder.mTitle.setText(mDateList.get(i).getTitle());
        viewHolder.mSummary.setText(mDateList.get(i).getSummary());
        viewHolder.mTime.setText(mDateList.get(i).getPublishTime().toString());
    }

    @Override
    public int getItemCount() {
        return mDateList.size();
    }
}
